﻿using FrameCore.LogSystem;
using MemoryPack;
using Share.Memory;

namespace Server.Module.WebSocket
{
    public static class NetGlobalFunctions
    {
        /// <summary>
        /// 服务器接收到客户端的消息
        /// </summary>
        public static void ReceiveMessage(EMessageMainType _eMessageMainType, EMessageSubType _eMessageSubType, int _messageId, byte[] _data)
        {
            switch (_eMessageMainType)
            {
                case EMessageMainType.Login:
                    switch (_eMessageSubType)
                    {
                        case EMessageSubType.Login:
                        {
                            LoginReq req = MemoryPackSerializer.Deserialize<LoginReq>(_data);
                            //NetReceiveFunctions.Receive_Login_Login(req, _messageId);
                        }
                            break;
                        default:
                            Log.Error($"未找到主类型{_eMessageMainType}，副类型{_eMessageSubType}相应的回调执行");
                            break;
                    }
                    break;
                case EMessageMainType.EnterGame:
                {
                    switch (_eMessageSubType)
                    {
                        case EMessageSubType.EnterGame:
                        {
                            EnterGameReq req = MemoryPackSerializer.Deserialize<EnterGameReq>(_data);
                            //NetReceiveFunctions.Receive_EnterGame_EnterGame(socketId, req, _messageId);
                        }
                            break;
                        default:
                            Log.Error($"未找到主类型{_eMessageMainType}，副类型{_eMessageSubType}相应的回调执行");
                            break;
                    }
                }
                    break;
                case EMessageMainType.Test1:
                {
                    Test1Req req = MemoryPackSerializer.Deserialize<Test1Req>(_data);
                    //NetReceiveFunctions.Receive_Test1_Test1(socketId, req, _messageId);
                }
                    break;
                case EMessageMainType.WxLogin:
                {
                    switch (_eMessageSubType)
                    {
                        case EMessageSubType.WxLogin:
                        {
                            WxLoginReq req = MemoryPackSerializer.Deserialize<WxLoginReq>(_data);
                            //NetReceiveFunctions.Receive_WxLogin_WxLogin(socketId, req, _messageId);
                        }
                            break;
                        default:
                            Log.Error($"未找到主类型{_eMessageMainType}，副类型{_eMessageSubType}相应的回调执行");
                            break;
                    }
                }
                    break;
                default:
                    Log.Error($"未找到主类型{_eMessageMainType}相应的回调执行");
                    break;
            }
        }
    }   
}